<?php defined('_JEXEC') or die('Restricted access'); ?>
<?php

// Initialize variables
$db		=& JFactory::getDBO();
$user	=& JFactory::getUser();
$config	=& JFactory::getConfig();
$now	=& JFactory::getDate();

//Ordering allowed ?
$ordering = ($this->lists['order'] == 'ordering');

$config 		= &JComponentHelper::getParams('com_yos_news_crawler');
$data_type 		= $config->get('data_type');

JHTML::_('behavior.tooltip');
?>
<form action="index.php?option=<?php echo $option; ?>" method="post" name="adminForm">
<table>
<tr>
	<td align="left" width="100%">
		<?php echo JText::_( 'Filter' ); ?>:
		<input type="text" name="search" id="search" value="<?php echo $this->lists['search'];?>" class="text_area" onchange="document.adminForm.submit();" />
		<button onclick="this.form.submit();"><?php echo JText::_( 'Go' ); ?></button>
		<button onclick="document.getElementById('search').value='';this.form.getElementById('filter_sectionid').value='-1';this.form.getElementById('catid').value='0';this.form.getElementById('filter_state').value='';this.form.submit();"><?php echo JText::_( 'Reset' ); ?></button>
	</td>
	<td nowrap="nowrap">
		<?php	echo $this->lists['cms'];	?>
		<?php	echo $this->lists['links'];	?>
	</td>
</tr>
</table>
<table class="adminlist">
	<thead>
		<tr>
			<th width="1%">
				<?php echo JText::_( 'Num' ); ?>
			</th>
			<th width="1%" class="title">
				<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count($this->rows); ?>);" />
			</th>
			<th class="title" width="59%">
				<?php echo JHTML::_('grid.sort',   JText::_('Title'), 'ynj.title', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
			</th>
			<th width="8%" nowrap="nowrap">
				<?php echo JHTML::_('grid.sort', JText::_('Last update'), 'ynj.last_update', @$this->lists['order_Dir'], @$this->lists['order']);?>
			</th>
			<th width="11%" nowrap="nowrap">
				<?php echo JHTML::_('grid.sort', JText::_('Link'), 'ync.link', @$this->lists['order_Dir'], @$this->lists['order']);?>
			</th>
			<th width="6%" nowrap="nowrap">
				<?php echo JHTML::_('grid.sort', JText::_('cms'), 'ynj.cms', @$this->lists['order_Dir'], @$this->lists['order']); ?>
			</th>	
			<th width="6%">
				<?php echo JHTML::_('grid.sort', JText::_('Published'), 'ynj.published', @$this->lists['order_Dir'], @$this->lists['order']);?>
			</th>
			<th width="6%">
				<?php echo JHTML::_('grid.sort', JText::_('Error counter'), 'ynj.error_counter', @$this->lists['order_Dir'], @$this->lists['order']);?>
			</th>				
			<th width="2%" nowrap="nowrap">
				<?php echo JHTML::_('grid.sort',   JText::_('ID'), 'ynj.id', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
			</th>
		</tr>
	</thead>
		<tfoot>
			<tr>
				<td colspan="9">
					<?php echo $this->pageNav->getListFooter(); ?>	
				</td>
			</tr>
		</tfoot>	
	<tbody>
	<?php
	$k = 0;
	$nullDate = $db->getNullDate();
	
	for ($i=0, $n=count($this->rows); $i < $n; $i++) {
		$row = $this->rows[$i];
		$published 	= JHTML::_('grid.published', $row, $i, 'publish_g.png','publish_x.png','jobs.' );	
		$link 		= JRoute::_( 'index.php?option='.$option.'&task=jobs.edit&cid[]='. $row->id );	
		$link_edit		= JRoute::_( 'index.php?option='.$option.'&task=link.edit&returndotask=linkmanager&cid[]='. $row->link_id );	
		?>
		<tr class="<?php echo "row$k"; ?>">
			<td><?php echo $this->pageNav->getRowOffset( $i ); ?></td>
			<td>
				<input type="checkbox" id="cb<?php echo $i; ?>" name="cid[]" value="<?php echo $row->id; ?>" onclick="isChecked(this.checked);" />
			</td>
			<td>
				<span class="editlinktip hasTip" title="<?php echo JText::_( 'Edit Job' );?>::<?php echo $row->title; ?>">
				<a href="<?php echo $link; ?>">
					<?php echo $row->title; ?></a> </span>						
			</td>
			<td align="center">
				<div>
					<span class="editlinktip hasTip" title="<?php echo JText::_( 'Time update' );?>::<?php echo $row->time_update; ?> (Minute)">
						<?php echo $row->last_update; ?>
					</span>
				</div>
			</td>
			<td align="center">
				<div style="float:left; margin:0 0 0 10px; z-index:6; ">
					<span class="editlinktip hasTip" title="<?php echo JText::_( 'Go to' );?>::<?php echo $row->link; ?>">
						<a href="<?php echo $row->link; ?>" target="_blank">
							<img src="components/com_yos_news_crawler/assets/images/url.png" />
							<p style="display:block; margin:0 auto; z-index:5;">Goto link</p>
						</a>
					</span>
					
				</div>
				<div align="center" style="margin:0px auto;position:absolute;width:11%; color:#BBBBBB;">
				<?php
					$web=parse_url($row->link);
					echo ($web['host']);
					
				 ?>
				 </div>
				<div style="float:right; margin:0 10px 0 0; z-index:6;">
					<span style="width:32px; height:32px" title="Edit link:: <?php echo $row->link; ?>" class="editlinktip hasTip">
						<a href="<?php echo $link_edit; ?>">
							<img src="components/com_yos_news_crawler/assets/images/icon-32-edit.png" />
							<p style="display:block; margin:0 auto">Edit link</p>
						</a>
						
					</span>
				</div>
				<div class="clr"></div>
			</td>
			<td align="center"><?php echo $row->cms; ?></td>
			<td align="center"><?php echo $published; ?></td>
			<td align="center">	<?php echo $row->error_counter; ?></td>			
			<td align="center">	<?php echo $row->id; ?></td>
		</tr>
		<?php
		$k = 1 - $k;
	}
	?>
	</tbody>
</table>
<input type="hidden" name="option" value="<?php echo $this->option; ?>" />
<input type="hidden" name="task" value="jobmanager" />
<input type="hidden" name="dotask" value="list" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $this->lists['order_Dir']; ?>" />
<?php echo JHTML::_( 'form.token' ); ?>
</form>
